package com.shmn.gongjiajumain.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.shmn.gongjiajumain.vo.purchaseincome.PurchaseIncomeMineFormVo;
import com.shmn.gongjiajumain.vo.purchaseincome.PurchaseincomesubmithistoryFromVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.shmn.gongjiajumain.entity.PurchaseIncomeSubmitEntity;
import com.shmn.gongjiajumain.service.PurchaseIncomeSubmitService;
import com.shmn.common.utils.PageUtils;
import com.shmn.common.utils.R;



/**
 * 记录采购入库申请
 *
 * @author chenshun
 * @email 1005074582@qq.com
 * @date 2023-05-14 16:40:27
 */
@RestController
@RequestMapping("gongjiajumain/purchaseincomesubmit")
public class PurchaseIncomeSubmitController {
    @Autowired
    private PurchaseIncomeSubmitService purchaseIncomeSubmitService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("gongjiajumain:purchaseincomesubmit:list")
    public R list(@RequestParam Map<String, Object> params){
        System.out.println(params);
        PageUtils page = purchaseIncomeSubmitService.queryPage(params);

        return R.ok().put("page", page);
    }

    @PostMapping("/list1")
    //@RequiresPermissions("gongjiajumain:purchaseincomesubmit:list")
    public R list1(@RequestBody PurchaseIncomeMineFormVo purchaseIncomeMineFormVo){
        System.out.println(purchaseIncomeMineFormVo);
        Map<String, Object> params = new HashMap<>();
        params.put("page",purchaseIncomeMineFormVo.getPageIndex());
        params.put("limit",purchaseIncomeMineFormVo.getPageSize());
        params.put("key",purchaseIncomeMineFormVo.getKey());
        System.out.println(params);
        PageUtils page = purchaseIncomeSubmitService.queryPage(params);

        return R.ok().put("page", page);
    }

    @PostMapping("/list2")
    //@RequiresPermissions("gongjiajumain:purchaseincomesubmit:list")
    public R list2(@RequestBody PurchaseincomesubmithistoryFromVo purchaseincomesubmithistoryFromVo){
        System.out.println(purchaseincomesubmithistoryFromVo);
        PageUtils page = purchaseIncomeSubmitService.queryPage1(purchaseincomesubmithistoryFromVo);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("gongjiajumain:purchaseincomesubmit:info")
    public R info(@PathVariable("id") Integer id){
		PurchaseIncomeSubmitEntity purchaseIncomeSubmit = purchaseIncomeSubmitService.getById(id);

        return R.ok().put("purchaseIncomeSubmit", purchaseIncomeSubmit);
    }

    /**
     * 保存
     */
    @RequestMapping("/saveInfo")
    //@RequiresPermissions("gongjiajumain:purchaseincomesubmit:save")
    public R save(@RequestBody PurchaseIncomeSubmitEntity purchaseIncomeSubmit){
		purchaseIncomeSubmitService.saveInfo(purchaseIncomeSubmit);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("gongjiajumain:purchaseincomesubmit:update")
    public R update(@RequestBody PurchaseIncomeSubmitEntity purchaseIncomeSubmit){
		purchaseIncomeSubmitService.updateById(purchaseIncomeSubmit);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("gongjiajumain:purchaseincomesubmit:delete")
    public R delete(@RequestBody Integer[] ids){
		purchaseIncomeSubmitService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
